Skip to content

[codex] Isolate translation langdetect imports on Windows#7949

Merged
kodjima33 merged 1 commit into
BasedHardware:mainfrom
tianmind-studio:codex/windows-translation-langdetect-stub
Jun 17, 2026
Merged

[codex] Isolate translation langdetect imports on Windows#7949
kodjima33 merged 1 commit into
BasedHardware:mainfrom
tianmind-studio:codex/windows-translation-langdetect-stub

Conversation

@tianmind-studio

@tianmind-studio tianmind-studio commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add a test-local langdetect fallback for translation optimization tests when the package is missing in lightweight backend environments.
  • Restore real utils and models package paths before importing translation modules, so earlier stub-heavy tests cannot make utils.translation or models.transcript_segment unreachable.
  • Keep the fallback narrow: it covers the detect, detect_langs, DetectorFactory, and LangDetectException surface used by these tests, and skips itself when the real langdetect package is installed.

Root cause

The translation tests already mock Redis and Google Translate, but they still import utils.translation, which imports langdetect at module load. On this Windows lightweight backend venv, standalone collection failed before the tests could run:

ModuleNotFoundError: No module named 'langdetect'

When collected after stub-heavy tests, a prior lightweight utils package stub could also hide the real backend/utils package, producing:

ModuleNotFoundError: No module named 'utils.translation'

Current status

  • Rebased on main at 1a5824403b68ce47c3b0909577cadc1242ba0d3f
  • Head refreshed to 3d13fdd672d9a7cb36dc366333f4a5caf6c1deee
  • GitHub currently reports the PR as mergeable

Validation

  • D:\codex-omi-work\.venvs\omi-backend-vad-refresh\Scripts\python.exe -m pytest backend\tests\unit\test_translation_optimization.py backend\tests\unit\test_translation_cost_optimization.py --collect-only -q --tb=short
    • 175 tests collected
  • D:\codex-omi-work\.venvs\omi-backend-vad-refresh\Scripts\python.exe -m pytest backend\tests\unit\test_translation_optimization.py backend\tests\unit\test_translation_cost_optimization.py -q --tb=short
    • 175 passed
  • D:\codex-omi-work\.venvs\omi-backend-vad-refresh\Scripts\python.exe -m pytest backend\tests\unit\test_translation_cost_optimization.py backend\tests\unit\test_translation_optimization.py -q --tb=short
    • 175 passed
  • D:\codex-omi-work\.venvs\omi-backend-vad-refresh\Scripts\python.exe -m pytest backend\tests\unit\test_action_item_date_validation.py backend\tests\unit\test_translation_optimization.py backend\tests\unit\test_translation_cost_optimization.py -q --tb=short
    • 201 passed
  • D:\codex-omi-work\.venvs\omi-backend-vad-refresh\Scripts\python.exe -m py_compile backend\tests\unit\test_translation_optimization.py backend\tests\unit\test_translation_cost_optimization.py
  • D:\codex-omi-work\.venvs\omi-backend-vad-refresh\Scripts\python.exe -m black --line-length 120 --skip-string-normalization --check backend\tests\unit\test_translation_optimization.py backend\tests\unit\test_translation_cost_optimization.py
    • 2 files would be left unchanged
  • git diff --check origin/main...HEAD
  • scripts/pre-commit with the backend Windows venv and local Dart SDK on PATH

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test-only stabilization (import isolation / stubs); zero product risk, CI not failing.

@tianmind-studio tianmind-studio force-pushed the codex/windows-translation-langdetect-stub branch from 49de74e to 9a6ad2c Compare June 16, 2026 14:52
@tianmind-studio tianmind-studio force-pushed the codex/windows-translation-langdetect-stub branch from 9a6ad2c to 3d13fdd Compare June 17, 2026 09:03

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test-only stabilization (translation langdetect imports), CI green

@kodjima33 kodjima33 merged commit b060e9a into BasedHardware:main Jun 17, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants